import React from 'react';
import ReactEcharts from '@/components/Echarts';
import { Empty } from 'antd';

const BurnoutChart = ({ data }) => {
    const { actualData, shouldData } = data;
    const xData = shouldData.map((item, index) => index);
    const option = {
        color: ['#597EF7', '#FFA22D'],
        tooltip: {
            trigger: 'axis'
        },
        grid: {
            right: 10,
            bottom: 30
        },
        legend: {
            x: 'right',
            y: 20,
            data: ['实际线', '参考线']
        },
        xAxis: [
            {
                type: 'category',
                name: '',
                boundaryGap: false,
                axisLine: {
                    lineStyle: {
                        color: 'rgba(0, 0, 0, 0.1)'
                    }
                },
                axisLabel: {
                    color: 'rgba(0, 0, 0, 0.45)'
                },
                splitLine: { show: false },
                axisTick: { show: false },
                data: xData
            }
        ],
        yAxis: [
            {
                type: 'value',
                name: '',
                axisTick: { show: false },
                axisLine: { show: false },
                axisLabel: {
                    interval: 20,
                    formatter: '{value}'
                }
            }
        ],
        series: [
            {
                name: '实际线',
                type: 'line',
                data: actualData
            },
            {
                name: '参考线',
                type: 'line',
                data: shouldData
            }
        ]
    };
    return (
        <>
            {actualData.length > 0 && shouldData.length > 0 ? (
                <ReactEcharts
                    style={{
                        width: '100%',
                        height: 300
                    }}
                    option={option}
                />
            ) : (
                <Empty />
            )}
        </>
    );
};
export default BurnoutChart;
